package com.mi.rabbit;

public class Rabbit {
	//兔子出生月份
	private int birthMonth;
	//兔子窝
	private RabbitHouse rabbitHouse;
	
	public Rabbit(int birthMonth , RabbitHouse rabbitHouse) {
		this.birthMonth = birthMonth;
		this.rabbitHouse = rabbitHouse;
	}
	
	//生小兔子的方法
	public void giveBirth(int currentMonth){
		if(currentMonth - birthMonth >= 3){
			Rabbit baby1 = new Rabbit(currentMonth, rabbitHouse);
			Rabbit baby2 = new Rabbit(currentMonth, rabbitHouse);
			rabbitHouse.addRabbit(baby1);
			rabbitHouse.addRabbit(baby2);
		}
	}
	
	public void die(int currentMonth){
		if(currentMonth - birthMonth == 5){
			rabbitHouse.removeRabbit(this);
		}
	}
}
